Developer Documentation

QuickTime 4 API Documentation

Wired Movies and Sprites

| Previous | Chapter Contents | Chapter Top | Next |

Setting Properties of the Sprite Track

Besides adding key frame samples and override samples to the sprite track, you may want to set one or more global properties of the sprite track. For example, if you want to define a background color for your sprite track, you must set the sprite track's background color property. You do this by creating a leaf atom of type kSpriteTrackPropertyBackgroundColor whose data is the desired background color.

After adding the override samples, AddSpriteTrackToMovie adds a background color to the sprite track, as shown in Listing 3-12 . The function calls QTNewAtomContainer to create a new atom container for sprite track properties. AddSpriteTrackToMovie adds a new atom of type kSpriteTrackPropertyBackgroundColor to the container and calls SpriteMediaSetSpriteProperty to set the sprite track's property.

After adding a background color, AddSpriteTrackToMovie notifies the movie controller that the sprite track has actions. If the hasActions parameter is true , this function calls QTNewAtomContainer to create a new atom container for sprite track properties. AddSpriteTrackToMovie adds a new atom of type kSpriteTrackPropertyHasActions to the container and calls SpriteMediaSetSpriteProperty to set the sprite track's property.

Finally, after specifying that the sprite track has actions, AddSpriteTrackToMovie notifies the sprite track to generate QTIdleEvents by adding a new atom of type kSpriteTrackPropertyQTIdleEventsFrequency to the container. This new atom specifies the frequency of QTEvent occurrences.

Listing 12 Adding sprite track properties, including a background color, actions, and frequency

{
        QTAtomContainer     myTrackProperties;
        RGBColor            myBackgroundColor;
        
        // add a background color to the sprite track
        myBackgroundColor.red = EndianU16_NtoB(0x8000);
        myBackgroundColor.green = EndianU16_NtoB(0);
        myBackgroundColor.blue = EndianU16_NtoB(0xffff);
        
        QTNewAtomContainer(&myTrackProperties);
        QTInsertChild(myTrackProperties, 0,
                        kSpriteTrackPropertyBackgroundColor, 1, 1,
                        sizeof(RGBColor), &myBackgroundColor, NULL);

        // tell the movie controller that this sprite track has actions
        hasActions = true;
        QTInsertChild(myTrackProperties, 0,
                        kSpriteTrackPropertyHasActions, 1, 1,
                        sizeof(hasActions), &hasActions, NULL);
    
        // tell the sprite track to generate QTIdleEvents
        myFrequency = EndianU32_NtoB(60);
        QTInsertChild(myTrackProperties, 0,
                    kSpriteTrackPropertyQTIdleEventsFrequency, 1, 1,
                        sizeof(myFrequency), &myFrequency, NULL);
        myErr = SetMediaPropertyAtom(myMedia, myTrackProperties);
        if (myErr != noErr)
            goto bail;

        QTDisposeAtomContainer(myTrackProperties);
    }


© 1999 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |